/*
 * DIM-SUM操作系统 -- 时钟头文件
 *
 * Copyright (C) 2017 谢宝友
 *
 * 作者: Baoyou Xie <baoyou.xie@aliyun.com>
 *
 * License terms: GNU General Public License (GPL) version 3
 *
 */

#ifndef __DIM_SUM_CLOCKSOURCE_H
#define __DIM_SUM_CLOCKSOURCE_H

#include <dim-sum/time.h>
#include <dim-sum/types.h>
struct clocksource {
	/*
	 * Hotpath data, fits in a single cache line when the
	 * clocksource itself is cacheline aligned.
	 */
	cycle_t (*read)(struct clocksource *cs);
	cycle_t cycle_last;
	cycle_t mask;
	u32 mult;
	u32 shift;
	u64 max_idle_ns;

	const char *name;
	int rating;

};

static inline s64 clocksource_cyc2ns(cycle_t cycles, u32 mult, u32 shift)
{
	return ((u64) cycles * mult) >> shift;
}
#endif